function ri = assembleRi(elements,model)
mesh = model.getMesh();
nf = mesh.countFaces();
nDofs = mesh.countDofs();
ri = zeros(nDofs,1);
for i=1:nf
    rie = computeRie(i,elements,model);
    dofs = mesh.getFace(i-1).getDofNumbers();
    len = size(dofs(:),1);
    for j=1:len
        if dofs(j)~=-1
            ri(dofs(j)+1) = ri(dofs(j)+1) + rie(j);
        end
    end
end
end
